﻿package mortal.game.view.copy.crossMainCity.mainCityPosition
{
    import Message.Game.*;
    import Message.Public.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.manager.msgTip.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.game.view.guildNew.*;
    import mortal.mvc.core.*;

    public class MainCityPostAppointRender extends GCellRenderer
    {
        private var _bg:GImageBitmap;
        private var _postIcon:GImageBitmap;
        private var _playerName:GTextFiled;
        private var _level:GTextFiled;
        private var _combat:BitmapNumberText;
        private var _appointBtn:GLoadingButton;
        private var _selectBg:ScaleBitmap;
        private var _info:SMainCityPositon;
        private var _isSelfKing:Boolean;
        private var _postType:int;

        public function MainCityPostAppointRender()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._bg = UIFactory.gImageBitmap("", 0, 0, this);
            this._postIcon = UIFactory.gImageBitmap("", 12, 14, this);
            var _loc_1:* = GlobalStyle.textFormatHuang2.center();
            _loc_1.size = 15;
            this._playerName = UIFactory.gTextField(Language.getString(21416), 156, 34, 220, 50, this, _loc_1);
            this._level = UIFactory.gTextField("Lv.55", 353, 34, 80, 25, this, _loc_1);
            this._combat = UIFactory.bitmapNumberText(485, 37, "SignUpNum2.png", 22, 23, -8, this, 13, BitmapNumberText.Mid);
            this._combat.text = "1000";
            this._appointBtn = UIFactory.gLoadingButton(ResFileConst.WrBtn, 442, 33, 82, 29, this);
            this._appointBtn.configEventListener(MouseEvent.CLICK, this.appointPost);
            this._selectBg = UIFactory.bg(8, -3, 545, this.height, this, ImagesConst.ForgingSelectBg);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._bg.dispose(param1);
            this._bg = null;
            this._postIcon.dispose(param1);
            this._postIcon = null;
            this._playerName.dispose(param1);
            this._playerName = null;
            this._level.dispose(param1);
            this._level = null;
            this._combat.dispose(param1);
            this._combat = null;
            this._selectBg.dispose(param1);
            this._selectBg = null;
            this._appointBtn.dispose(param1);
            this._appointBtn = null;
            this._info = null;
            super.disposeImpl(param1);
            return;
        }// end function

        override public function set selected(param1:Boolean) : void
        {
            super.selected = param1;
            if (param1)
            {
                this._selectBg.visible = true;
            }
            else
            {
                this._selectBg.visible = false;
            }
            return;
        }// end function

        private function appointPost(event:MouseEvent) : void
        {
            var _loc_2:Object = null;
            if (this._appointBtn.styleName == ResFileConst.WrBtn)
            {
                if (!MainCityAppointSmallWin.isViewShow)
                {
                    _loc_2 = {view:MainCityAppointSmallWin.instance, index:GuildNewModule.Member};
                    Dispatcher.dispatchEvent(new DataEvent(EventName.GuildOpenAndTweenCenterWin, _loc_2));
                }
                MainCityAppointSmallWin.instance.selectIndex = this._postType;
            }
            else if (this._appointBtn.styleName == ResFileConst.XrBtn)
            {
                if (this._isSelfKing)
                {
                    if (this._info)
                    {
                        GameProxy.guild.postionOper(Cache.instance.role.entityInfo.entityId.id, this._info.officer, EMainCityPosition._EMainCityNoMember);
                    }
                }
                else
                {
                    MsgManager.showRollTipsMsg(Language.getString(21417), MsgRollTipsType.msgRollTips3);
                }
            }
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            var _loc_2:SMainCityPositons = null;
            super.data = param1;
            this._info = param1.info;
            this._isSelfKing = param1.isSelfKing;
            this._postType = param1.postType;
            this._bg.imgUrl = "MainCityPostBg_" + (int((this._postType - 1) / 2) + 1);
            this._postIcon.imgUrl = "MainCityPostType_" + this._postType;
            this._appointBtn.visible = this._isSelfKing && this._postType != EMainCityPosition._EMainCityKing;
            if (this._info)
            {
                if (this._isSelfKing)
                {
                    this._appointBtn.styleName = ResFileConst.XrBtn;
                    this._appointBtn.move(442 - 219, 57);
                }
                _loc_2 = Cache.instance.mainCity.sMainCityPositons;
                this._playerName.text = NameUtil.getProxyName(this._info.officer.entityId) + "_" + _loc_2.guildName + "\n" + this._info.officer.name;
                this._playerName.y = this._isSelfKing ? (10) : (25);
                this._level.text = "Lv. " + this._info.officer.level.toString();
                this._combat.text = this._info.officer.combat.toString();
            }
            else
            {
                if (this._isSelfKing)
                {
                    this._appointBtn.styleName = ResFileConst.WrBtn;
                    this._appointBtn.move(442, 33);
                }
                this._playerName.text = Language.getString(21416);
                this._playerName.y = 34;
                this._level.text = "";
                this._combat.text = "";
            }
            this._appointBtn.drawNow();
            return;
        }// end function

    }
}
